package com.witmore.skyline.web.controller.vo.param;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * Description: PageParamVO
 * Author: 豆子高
 * Date: 2025/2/27 14:02
 */
@NoArgsConstructor
@Data
public class PageParamVO {

    private Integer page = 1;

    private Integer size = 20;

    private String sortField;

    /**
     * 排序方式 默认降序 DESC ASC
     */
    private String sortOrder ;


    public Integer getPage() {
        if (page == null) {
            page = 1;
        }
        if (page < 1) {
            this.page = 1;
        }
        return page;
    }

    public Integer getSize() {
        if (size == null) {
            size = 20;
        }
        if (size == -1) {
            this.size = 9999999;
        } else if (size < 1) {
            this.size = 20;
        }
        if (size > 10000) {
            this.size = 100;
        }
        return size;
    }

    public PageParamVO(Integer page, Integer size) {
        this.page = page;
        this.size = size;
    }
}
